import Vue from 'vue';
import Router from 'vue-router';

const originalReplace = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err);
};
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

Vue.use(Router);

export default new Router({
    routes: [
        {
            path: '/',
            redirect: '/index'
        },
        {
            path: '/index',
            component: () => import('../components/page/index.vue'),
            meta: { title: '茶文化交流平台' }
        },
        {
            path: '/index-tea',
            component: () => import('../components/page/index-tea.vue'),
            meta: { title: '茶文化交流平台' }
        },
        {
            path: '/search',
            component: () => import('../components/page/search.vue'),
            meta: { title: '置卖物品 | 茶文化交流平台' }
        },
        {
            path: '/me',
            component: () => import('../components/page/me.vue'),
            meta: { title: '个人中心 | 茶文化交流平台' }
        },
        {
            path: '/message',
            component: () => import('../components/page/message.vue'),
            meta: { title: '消息 | 茶文化交流平台' }
        },
        {
            path: '/release',
            component: () => import('../components/page/release.vue'),
            meta: { title: '发布物品 | 茶文化交流平台' }
        },
        {
            path: '/article',
            component: () => import('../components/page/article.vue'),
            meta: { title: '发布文章 | 茶文化交流平台' }
        },
        {
            path: '/details-tea',
            component: () => import('../components/page/tea-details.vue'),
            meta: { title: '物品详情 | 茶文化交流平台' }
        },
        {
            path: '/details',
            component: () => import('../components/page/details.vue'),
            meta: { title: '物品详情 | 茶文化交流平台' }
        },
        {
            path: '/order',
            component: () => import('../components/page/order.vue'),
            meta: { title: '订单详情 | 茶文化交流平台' }
        },
        {
            path: '/login',
            component: () => import('../components/page/login.vue'),
            meta: { title: '登录 | 茶文化交流平台' }
        },
        {
            path: '/sign-in',
            component: () => import('../components/page/sign-in.vue'),
            meta: { title: '注册 | 茶文化交流平台' }
        },
        {
            path: '/login-admin',
            component: () => import('../components/page/login-admin.vue'),
            meta: { title: '后台登陆' }
        },
        {
            path: '/platform-admin',
            component: () => import('../components/page/platform-admin.vue'),
            meta: { title: '后台管理' }
        },
        {
            path: '/news',
            component: () => import('../components/page/news.vue'),
            meta: { title: '新闻列表' }
        },
        {
            path: '/tea_ceremony',
            component: () => import('../components/page/tea_ceremony.vue'),
            meta: { title: '茶艺知多少 | 茶文化交流平台' }
        },
        {
            path: '/tea_science',
            component: () => import('../components/page/tea_science.vue'),
            meta: { title: '视频列表 | 茶文化交流平台' }
        },
        {
            path: '/contact_us',
            component: () => import('../components/page/contact_us.vue'),
            meta: { title: '关于我们 | 茶文化交流平台' }
        },
        {
            path: '/science-details',
            component: () => import('../components/page/science-details.vue'),
            meta: { title: '视频详情 | 茶文化交流平台' }
        },
        {
            path: '/community',
            component: () => import('../components/page/community.vue'),
            meta: { title: '茶社区 | 茶文化交流平台' }
        },
        {
            path: '/answer',
            component: () => import('../components/page/answer.vue'),
            meta: { title: '茶社区 | 发表观点' }
        },
        {
            path: '/looking',
            component: () => import('../components/page/looking.vue'),
            meta: { title: '茶社区 | 查看文章' }
        },
        {
            path: '/caizhai',
            component: () => import('../components/page/caizhai.vue'),
            meta: { title: '茶园采摘 | 茶文化交流平台' }
        },
        {
            path: '/discuss',
            component: () => import('../components/common/discuss.vue'),
            meta: { title: '话题' }
        },
        {
            path: '*',
            redirect: '/'
        }
    ]
});
